﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Security.Permissions;
using System.Collections;
using System.Web.UI;
using System.Collections.ObjectModel;

namespace Beetle.Web.UI.WebControls
{
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class SearchItemCollection : Collection<SearchItemBase>
    {
        private SearchView owner = null;
        public SearchItemCollection()
            : this(null)
        {

        }

        public SearchItemCollection(SearchView searchView)
        {
            this.owner = searchView;
        }

        protected override void InsertItem(int index, SearchItemBase item)
        {
            if (this.owner != null)
            {
                item.Owner = this.owner;

            }

            base.InsertItem(index, item);

            for (int i = 0; i < this.Count; i++)
            {
                this[i].Index = i;
            }
        }
    }
}
